Crate phaneron_plugin

source ·
Expand description

This module defines the interfaces to be implemented for a Phaneron plugin to be successfully loaded.

To create a plugin you must have a function annotated with the #[export_root_module] from the abi_stable crate. This function should return a PhaneronPluginRootModule which acts as the handle which can be used to initialize your plugin. This first function should not perform any additional work such as loading assets etc. as your plugin will be given an opportunity to initialize itself later.

You should then have a load function that is annotated using the #[sabi_external_fn] macro from the abi_stable crate. This function is the initializer for your plugin and is where you can load assets that are globally required and pre-allocate large amounts of memory if required. This function is allowed to fail and will only be called once. If it fails then the plugin will not be loaded and Phaneron will not attempt to load the plugin again. If failing, please return some useful error message.

#[export_root_module]
fn instantiate_root_module() -> PhaneronPluginRootModuleRef {
    PhaneronPluginRootModule { load }.leak_into_prefix()
}

#[sabi_extern_fn]
pub fn load(context: PhaneronPluginContext) -> RResult<PhaneronPlugin, RString> {
    log::set_logger(phaneron_plugin::get_logger(&context)).unwrap();
    log::set_max_level(LevelFilter::Trace);
    let plugin = DemoPlugin {};

    ROk(PhaneronPlugin_TO::from_value(plugin, TD_Opaque))
}

The returned plugin is of type DemoPlugin in this instance, which implements the PhaneronPlugin trait. This object will be used to create nodes from your plugin and manage its lifecycle. Refer to the documentation of PhaneronPlugin.

Modules

Structs

Enums

  • Supported audio channel layouts.
  • Supported audio I/O formats. Audio will be converted to 32 bit floating-point on input.
  • Built-in colour space definitions.
  • Supported interlacing modes.
  • This should not be used by plugins, it is consumed by Phaneron to carry log messages across the FFI boundary.
  • Available shader parameter types, these do not need to be directly consumed by plugins.
  • Supported pixel packing formats.

Constants

Traits

  • This trait is used to allow the logger to be used across the FFI boundary. It should not be consumed by plugins.

Functions

  • Returns the logger for a plugin which can then be used to pass log messages to Phaneron.

Type Definitions